package com.liangzhong.model.tradeCenter.sales
{
	import com.liangzhong.model.tradeCenter.AuctionPlayerVo;

	/**
	 * 交易球员数据处理 
	 * @author Administrator
	 * 
	 */	
	public class TradePlayerDataHandler
	{
		public function TradePlayerDataHandler()
		{
		}
		/**
		 * 投放球员数据 
		 */
		public var salesPlayerVec:Vector.<SalesPlayerVo>;
		/**
		 *市场球员列表 
		 */
		public var marketPlayerVec:Vector.<AuctionPlayerVo>;
		/**
		 *市场球员列表 
		 */
		public var auctionPlaeryVec:Vector.<AuctionPlayerVo>;
		/**
		 *关注球员列表 
		 */
		public var attentionPlayerVec:Vector.<AuctionPlayerVo>;
		/**
		 *我的商品球员列表  
		 */
		public var myproductPlayerVec:Vector.<AuctionPlayerVo>;
		
		/**
		 *解析投放数据 
		 * @param $obj
		 * 
		 */
		public function analysisSalesData($arr:Array):void
		{
			if(salesPlayerVec == null)salesPlayerVec = new Vector.<SalesPlayerVo>();
			salesPlayerVec.splice(0,salesPlayerVec.length);
			var sales:SalesPlayerVo;
			var len:int = $arr.length;
			for(var i:int = 0;i < len;i++)
			{
				sales = new SalesPlayerVo();
				sales.analysisData($arr[i]);
				salesPlayerVec.push(sales);
			}
			salesPlayerVec.sort(sort);
		}
		private function sort(a:SalesPlayerVo,b:SalesPlayerVo):Number
		{
//			if(a.number > b.number)return 1;
//			if(a.number < b.number)return -1;
			return 0;
		}
		/**
		 *解析市场数据 
		 * @param $arr
		 * 
		 */
		public function analysisMarketData($arr:Array,$search:String = null):void
		{
			if(marketPlayerVec == null)marketPlayerVec = new Vector.<AuctionPlayerVo>();
			marketPlayerVec.splice(0,marketPlayerVec.length);
			var vo:AuctionPlayerVo;
			var len:int = $arr.length;
			for(var i:int = 0;i < len;i++)
			{
				vo = new AuctionPlayerVo();
				vo.analysisData($arr[i]);
				vo.searchPlacer($search);
				marketPlayerVec.push(vo);
			}
			if($search != null)
			{
				marketPlayerVec.sort(sort);
				function sort(a:AuctionPlayerVo,b:AuctionPlayerVo):Number
				{
					if(a.search > b.search)return 1;
					if(a.search < b.search)return -1;
					return 0;
				}
			}
		}
		/**
		 *解析竞拍数据 
		 * @param $arr
		 * 
		 */
		public function analysisAuctionData($arr:Array):void
		{
			if(auctionPlaeryVec == null)auctionPlaeryVec = new Vector.<AuctionPlayerVo>();
			auctionPlaeryVec.splice(0,auctionPlaeryVec.length);
			var vo:AuctionPlayerVo;
			var len:int = $arr.length;
			for(var i:int = 0;i < len;i++)
			{
				vo = new AuctionPlayerVo();
				vo.analysisData($arr[i]);
				auctionPlaeryVec.push(vo);
			}
		}
		/**
		 *解析关注信息 
		 * @param $arr
		 * 
		 */		
		public function analysisAttentionData($arr:Array):void
		{
			if(attentionPlayerVec == null)attentionPlayerVec = new Vector.<AuctionPlayerVo>();
			attentionPlayerVec.splice(0,attentionPlayerVec.length);
			var vo:AuctionPlayerVo;
			var len:int = $arr.length;
			for(var i:int = 0;i < len;i++)
			{
				vo = new AuctionPlayerVo();
				vo.analysisData($arr[i]);
				attentionPlayerVec.push(vo);
			}
		}
		/**
		 *解析我的商品列表 
		 * @param $arr
		 * 
		 */
		public function analysisMyproduct($arr:Array):void
		{
			if(myproductPlayerVec == null)myproductPlayerVec = new Vector.<AuctionPlayerVo>();
			myproductPlayerVec.splice(0,myproductPlayerVec.length);
			var vo:AuctionPlayerVo;
			var len:int = $arr.length;
			for(var i:int = 0;i < len;i++)
			{
				vo = new AuctionPlayerVo();
				vo.analysisData($arr[i]);
				myproductPlayerVec.push(vo);
			}
		}
		
	}
}